package com.mhg.generic;

import java.util.ArrayList;
import java.util.Iterator;

import com.mhg.collection.bean.Student;

public class Demo_02 {

	public static void main(String[] args) {
		ArrayList<Student> al = new ArrayList<>();
		al.add(new Student("张三", 23));
		al.add(new Student("李四",24));
		
		Iterator<Student> it = al.iterator();
		while(it.hasNext()){
			Student stu = it.next();//定义泛型后 不用再向下转型了
			System.out.println(stu.getName());
		}
	}

}
